<?php

namespace app\api\controller;
use think\admin\Controller;

use think\Request;
class News extends Controller
{
    private $default_type = 'json';
    protected $middleware = ['check'];

    /**
     * 文章详情
     * @return void
     */
    public function info(){
         if($this->request->debug != 1){
            $id = input('id','','trim,intval');
            if(empty($id)){
                return \Tools::returnMsg(false, array(
                    'code' => '10004',
                    'message' => '参数有误'
                ), $this->default_type);
            }
            $NewsModel = new \app\api\model\DataNewsItem();
            $info = $NewsModel->getOne(array(
                'id'    => $id
            ),'id,name,cover,content,num_like,num_read,create_at');
            return \Tools::returnMsg(true,$info,$this->default_type);
         }else{
            return \Tools::returnMsg(true,array(
                'id'    =>1,
                'name'  => '商品上架',
                'cover' => '/static/img/1.jpg',
                'content'=>'富文本',
                'create_at'=> '2022-09-12 12:15:10'
            ),$this->default_type);
         }
    }

}
